//
//  LKImagePickerManager.h
//  LKImagePickerDemo
//
//  Created by LIUKUN-PC on 16/5/26.
//  Copyright © 2016年 liukun. All rights reserved.
//

//仅适用于iOS8.0Later

#import <UIKit/UIKit.h>
@class PHAsset;

/**
 *  选择图片后的回调 Block
 *
 *  @param photos                Image对象数组
 *  @param assets                图片在图库中的模型数组
 *  @param isSelectOriginalPhoto 是否为原图
 *  @param isFromCamera          是否来自相机
 */

typedef void(^LKPickImagesFinishedBlock)(NSArray<UIImage *> *photos, NSArray<PHAsset *> *assets, BOOL isSelectOriginalPhoto, BOOL isFromCamera);

/**
 *  选择视频后的回调 Block
 *
 *  @param coverImage 视频封面图
 *  @param asset      视频在图库中的模型
 *  @param path       视频在tmp文件夹中是路径
*  @param isFromCamera          是否来自相机
 */
typedef void(^LKPickVideoFinishedBlock)(UIImage *coverImage, PHAsset *asset, NSString *path, BOOL isFromCamera);

/**
 获取选取的图片或视频源地址, 图片地址无法访问

 @param asset       图片在图库中的模型
 @param completion 完成回调
 */
UIKIT_EXTERN void LKImagePikerGetAssertUrl(PHAsset *asset, void(^completion)(NSURL *url));


@interface LKImagePickerManager : NSObject

/** 当前控制器，用于推出其他界面 */
@property (nonatomic, weak) UIViewController *currentViewController;

/**
 *  创建imagePicker对象的工厂方法
 *
 *  @return 对象实例
 */
+ (instancetype)imagePickerManagerWithCurrentViewController:(UIViewController *)currentViewController;

#pragma mark - 图片选择，可多选

/**
 *  展示图片选择菜单, 包括 拍照 和 从手机相册选择
 *
 *  @param selectedAssets              已选照片在照片库中的assert图片模型数组
 *  @param isSelectOriginalPhoto       是否为原图
 *  @param maxImagesCount              最大可选图片数量
 *  @param didFinishPickingPhotosBlock 完成选择的回调
 */
- (void)showImagesPickerSheetViewWithSelectedAssets:(NSMutableArray<PHAsset *> *)selectedAssets
                              isSelectOriginalPhoto:(BOOL)isSelectOriginalPhoto
                                     maxImagesCount:(NSInteger)maxImagesCount
                      didFinishPickingPhotosHandler:(LKPickImagesFinishedBlock)didFinishPickingPhotosBlock;

/**
 *  打开相机拍照
 *
 *  @param takePhotosDidFinishBlcok 完成回调，image:图片，照片库中的asset图片模型
 *  @param isSelectOriginalPhoto       照片是否为原图
 */
- (void)openCameraWithIsSelectOriginalPhoto:(BOOL)isSelectOriginalPhoto takePhotosDidFinishHandler:(LKPickImagesFinishedBlock)takePhotosDidFinishBlock;

/**
 *  预览选择的照片并可以删除已选照片
 *
 *  @param selectedAssets              已选照片在照片库中的assert图片模型数组
 *  @param selectedPhotos              已选照片的图片数组
 *  @param index                       当前预览的照片在已选照片中的索引
 *  @param isSelectOriginalPhoto       默认已选照片是否为原图
 *  @param didChangeSelectedAssetBlock 修改后的回调
 */
- (void)previewPhotosWithSelectedAssets:(NSMutableArray<PHAsset *> *)selectedAssets
                         selectedPhotos:(NSMutableArray<UIImage *> *)selectedPhotos
                                  index:(NSInteger)index
                  isSelectOriginalPhoto:(BOOL)isSelectOriginalPhoto
          didChangeSelectedAssetHandler:(LKPickImagesFinishedBlock)didChangeSelectedAssetBlock;

/**
 *  打开图库选择
 *
 *  @param selectedAssets              默认已选照片在照片库中的assert图片模型数组
 *  @param isSelectOriginalPhoto       默认已选照片是否为原图
 *  @param maxImagesCount              最大可选图片张数
 *  @param didFinishPickingPhotosBlock 选择图片后的回调，

 */
- (void)pickPhotosWithSelectedAssets:(NSMutableArray<PHAsset *> *)selectedAssets
               isSelectOriginalPhoto:(BOOL)isSelectOriginalPhoto
                      maxImagesCount:(NSInteger)maxImagesCount
       didFinishPickingPhotosHandler:(LKPickImagesFinishedBlock)didFinishPickingPhotosBlock;

#pragma mark - 视频选择, 只能单选

/**
 *  展示视频选择菜单,保存相机录像 和 从图库中选择
 *
 *  @param didFinishPickingVideoBlock 完成回调
 */
- (void)showVideoPickerSheetViewWithDidFinishPickingVideoHandler:(LKPickVideoFinishedBlock)didFinishPickingVideoBlock;


/**
 *  打开相机录制视频
 *
 *  @param videoRecordDidFinishBlcok 录制视频完成时的回调
 */
- (void)openCameraWithVideoRecordDidFinishHandler:(LKPickVideoFinishedBlock)videoRecordDidFinishBlcok;

/**
 *  从图库里选择视频
 *
 *  @param didFinishPickingVideoBlock 选择视频后的回调
 */
- (void)pickVideoWithDidFinishPickingVideoHandler:(LKPickVideoFinishedBlock)didFinishPickingVideoBlock;

@end
